<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>单击该按钮改变列表项的顺序</title>
</head>

<body>


  <ul id="myList">
    <li>Coffee</li>
    <li>Tea</li>
    <li>Water</li>
    <li>Milk</li>
  </ul>

  <p id="demo">单击该按钮改变列表项的顺序</p>
  <button onclick="myFunction()">点我</button>
  <script>
    function myFunction() {
      var list = document.getElementById("myList");
      var node = list.getElementsByTagName("li");
      list.insertBefore(node[3], node[1]);
    }
  </script>
</body>

</html>